#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;
const int N = 210;

int n, m;
int id[N][N];
int p[N * N];

int find(int x){
    if(x != p[x]){
        p[x] = find(p[x]);
    }

    return p[x];
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    scanf("%d%d", &n, &m);
    for(int i = 1, cnt = 1; i <= n; i ++){
        for(int j = 1; j <= n; j ++, cnt ++){
            id[i][j] = cnt;
        }
    }

    for(int i = 1; i <= n * n; i ++){
        p[i] = i;
    }

    bool flag = false;
    int cnt = 0;
    for(int i = 1; i <= m; i ++){
        int a, b;
        char op[2];
        int na, nb;
        cin >> a >> b >> op;
        if(op[0] == 'D'){
            na = a + 1, nb = b;
        }else{
            na = a, nb = b + 1;
        }

        int pa = find(id[a][b]), pb = find(id[na][nb]);

        if(pa == pb){
            flag = true;
            cnt = i;
            break;
        }else{
            p[pa] = pb;
        }
    }


    if(flag){
        printf("%d\n", cnt);
    }else{
        printf("draw\n");
    }



    return 0;
}